In this section, let \( R \) be an integral domain.

\subsection{Prime and irreducible elements}
Recall that an element \( a \in R \) is a unit if it has a multiplicative inverse in \( R \).
Equivalently, an element \( a \) is a unit if and only if \( (a) = R \).
Indeed, if \( (a) = R \), then \( 1 \in (a) \) hence there exists a multiple of \( a \) equal to 1.
We denote the set of units in \( R \) by \( R^\times \).
\begin{definition}
	An element \( a \in R \) \textit{divides} \( b \in R \), written \( a \mid b \), if there exists \( c \in R \) such that \( b = ac \).
	Equivalently, \( (b) \subseteq (a) \).

	Two elements \( a, b \in R \) are \textit{associates} if \( a = bc \) where \( c \) is a unit.
	Informally, the two elements differ by multiplication by a unit.
	Equivalently, \( (a) = (b) \).
\end{definition}
\begin{definition}
	An element \( r \in R \) is \textit{irreducible} if \( r \) is not zero or a unit, and \( r = ab \) implies \( a \) is a unit or \( b \) is a unit.
	An element \( r \in R \) is \textit{prime} if \( r \) is not zero or a unit, and \( r \mid ab \) implies \( r \mid a \) or \( r \mid b \).
\end{definition}
\begin{remark}
	These properties depend on the ambient ring \( R \); for instance, 2 is prime and irreducible in \( \mathbb Z \), but neither prime nor irreducible in \( \mathbb Q \).
	The polynomial \( 2X \) is irreducible in \( \mathbb Q[X] \), but not in \( \mathbb Z[X] \).
\end{remark}
\begin{lemma}
	\( (r) \vartriangleleft R \) is a prime ideal if and only if \( r = 0 \) or \( r \) is prime.
\end{lemma}
\begin{proof}
	Suppose \( (r) \) is a prime ideal with \( r \neq 0 \).
	Since prime ideals are proper, \( r \) cannot be a unit.
	Suppose \( r \mid ab \), or equivalently, \( ab \in (r) \).
	By the definition of a prime ideal, \( a \in (r) \) or \( b \in (r) \).
	Hence, \( r \mid a \) or \( r \mid b \).
	By definition of a prime element, \( r \) is prime.

	Conversely, first note that the zero ideal \( (0) = \qty{0} \) is a prime ideal, since \( R \) is an integral domain.
	Suppose \( r \) is prime.
	We know \( (r) \neq R \) since \( r \) is not a unit.
	If \( ab \in (r) \), then \( r \mid ab \), so \( r \mid a \) or \( r \mid b \), giving \( a \in (r) \) or \( b \in (r) \) as required for \( (r) \) to be a prime ideal.
\end{proof}
\begin{lemma}
	Prime elements are irreducible.
\end{lemma}
\begin{proof}
	Let \( r \) be prime.
	Then \( r \) is nonzero and not a unit.
	Suppose \( r = ab \).
	Then, in particular, \( r \mid ab \), so \( r \mid a \) or \( r \mid b \) by primality.
	Let \( r \mid a \) without loss of generality.
	Hence \( a = rc \) for some element \( c \in R \).
	Then, \( r = ab = rcb \), so \( r(1-cb) = 0 \).
	Since \( R \) is an integral domain, and \( r \neq 0 \), we have \( cb = 1 \), so \( b \) is a unit.
\end{proof}
\begin{example}
	The converse does not hold in general.
	Let
	\[
		R = \mathbb Z[\sqrt{-5}] = \qty{a+b\sqrt{-5} \colon a,b \in \mathbb Z} \leq \mathbb C;\quad R \cong \faktor{\mathbb Z[X]}{(X^2 + 5)}
	\]
	Since \( R \) is a subring of the field \( \mathbb C \), it is an integral domain.
	We can define the \textit{norm} \( N \colon R \to \mathbb Z \) by \( N(a+b\sqrt{-5}) = a^2 + 5b^2 \geq 0 \).
	Note that this norm is multiplicative: \( N(z_1 z_2) = N(z_1) N(z_2) \).

	We claim that the units are exactly \( \pm 1 \).
	Indeed, if \( r \in R^\times \), then \( rs = 1 \) for some element \( s \in R \).
	Then, \( N(r) N(s) = N(1) = 1 \), so \( N(r) = N(s) = 1 \).
	But the only elements \( r \in R \) with \( N(r) = 1 \) are \( r = \pm 1 \).

	We will now show that the element \( 2 \in R \) is irreducible.
	Suppose \( 2 = rs \) for \( r,s \in R \).
	By the multiplicative property of \( N \), \( N(2) = 4 = N(r) N(s) \) can only be satisfied by \( N(r), N(s) \in \qty{1,2,4} \).
	Since \( a^2 + 5b^2 = 2 \) has no integer solutions, \( R \) has no elements of norm 2.
	Hence, either \( r \) or \( s \) has unit norm and is thus a unit by the above discussion.
	We can show similarly that \( 3, 1 + \sqrt{-5}, 1 - \sqrt{-5} \) are irreducible, as there exist no elements of norm 3.

	We can now compute directly that \( (1 + \sqrt{-5})(1-\sqrt{-5}) = 6 = 2 \cdot 3 \), hence \( 2 \mid (1 + \sqrt{-5})(1-\sqrt{-5}) \).
	But \( 2 \nmid (1 + \sqrt{-5}) \) and \( 2 \nmid (1 - \sqrt{-5}) \), which can be checked by taking norms.
	Hence, 2 is irreducible but not a prime.

	In order to construct this example, we have exhibited two factorisations of 6 into irreducibles: \( (1 + \sqrt{-5})(1-\sqrt{-5}) = 6 = 2 \cdot 3 \).
	Since \( R^\times = \qty{\pm 1} \), these irreducibles in the factorisations are not associates.
\end{example}

\subsection{Principal ideal domains}
\begin{definition}
	An integral domain \( R \) is a \textit{principal ideal domain} if all ideals are principal ideals.
	In other words, for all ideals \( I \), there exists an element \( r \) such that \( I = (r) \).
\end{definition}
\begin{example}
	\( \mathbb Z \) is a principal ideal domain.
\end{example}
\begin{proposition}
	In a principal ideal domain, all irreducible elements are prime.
\end{proposition}
\begin{proof}
	Let \( r \in R \) be irreducible, and suppose \( r \mid ab \).
	If \( r \mid a \), the proof is complete, so suppose \( r \nmid a \).
	Since \( R \) is a principal ideal domain, the ideal \( (a,r) \) is generated by a single element \( d \in R \).
	In particular, since \( r \in (d) \), we have \( d \mid r \) so \( r = cd \) for some \( c \in R \).

	Since \( r \) is irreducible, either \( c \) or \( d \) is a unit.
	If \( c \) is a unit, \( (a,r) = (r) \), so in particular \( r \mid a \), which contradicts the assumption that \( r \nmid a \), so \( c \) cannot be a unit.
	Thus, \( d \) is a unit.
	In this case, \( (a,r) = R \).
	By definition of \( (a,r) \), there exist \( s, t \in R \) such that \( 1 = sa + tr \).
	Then, \( b = sab + trb \).
	We have \( r \mid sab \) since \( r \mid ab \), and we know \( r \mid trb \).
	Hence \( r \mid b \) as required.
\end{proof}
\begin{lemma}
	Let \( R \) be a principal ideal domain.
	Then an element \( r \) is irreducible if and only if \( (r) \) is maximal.
\end{lemma}
\begin{proof}
	Suppose \( r \) is irreducible.
	Since \( r \) is not a unit, \( (r) \neq R \).
	Suppose \( (r) \subseteq J \subseteq R \) where \( J \) is an ideal in \( R \).
	Since \( R \) is a principal ideal domain, \( J = (a) \) for some \( a \in R \).
	In particular, \( r = ab \) for some \( b \in R \), since \( (r) \subseteq J \).
	Since \( r \) is irreducible, either \( a \) or \( b \) is a unit.
	But if \( a \) is a unit, we have \( J = R \).
	If \( b \) is a unit, then \( a \) and \( r \) are associates so they generate the same ideal.
	Hence, \( (r) \) is maximal.

	Conversely, suppose \( (r) \) is maximal.
	Note that \( r \) is not a unit, since \( (r) \neq R \).
	Suppose \( r = ab \).
	Then \( (r) \subseteq (a) \subseteq R \).
	But since \( (r) \) is maximal, either \( (a) = (r) \) or \( (a) = R \).
	If \( (a) = (r) \), then \( b \) is a unit.
	If \( (a) = R \), then \( a \) is a unit.
	Hence \( r \) is irreducible.
	Note that this direction of the proof did not require that \( R \) was a principal ideal domain, however \( R \) must still be an integral domain.
\end{proof}
\begin{remark}
	Let \( R \) be a principal integral domain, and \( 0 \neq r \in R \).
	Then, \( (r) \) is maximal if and only if \( r \) is irreducible, which is true if and only if \( r \) is prime, which is equivalent to the fact that \( (r) \) is prime.
	Hence, the maximal ideals are the nonzero prime ideals.
\end{remark}
\begin{definition}
	An integral domain is a \textit{Euclidean domain} if there exists a function \( \varphi \colon R \setminus \qty{0} \to \mathbb Z_{\geq 0} \) such that, for all \( a, b \in R \).
	\begin{enumerate}
		\item if \( a \mid b \) then \( \varphi(a) \leq \varphi(b) \);
		\item if \( b \neq 0 \) then \( \exists q, r \in R \) such that \( a = bq + r \) and either \( r = 0 \) or \( \varphi(r) < \varphi(b) \).
	\end{enumerate}
	Such a \( \varphi \) is called a \textit{Euclidean function}.
\end{definition}
\begin{example}
	\( \mathbb Z \) is a Euclidean domain, where the Euclidean function \( \varphi \) is the absolute value function.
\end{example}
\begin{proposition}
	Euclidean domains are principal ideal domains.
\end{proposition}
\begin{proof}
	Let \( R \) have Euclidean function \( \varphi \).
	Let \( I \vartriangleleft R \) be a nonzero ideal.
	Let \( b \in I \setminus \qty{0} \) that minimises \( \varphi(b) \).
	Then \( (b) \subseteq I \).
	For any element \( a \in I \), we can use the Euclidean algorithm to show \( a = bq + r \) where \( r = 0 \) or \( \varphi(r) < \varphi(b) \).
	But since \( r = a - bq \in I \), \( \varphi(r) \) cannot be lower than the minimal element \( \varphi(b) \).
	Thus \( r = 0 \), so \( a = bq \).
	Hence, \( I = (b) \), so all ideals are principal.
\end{proof}
\begin{remark}
	In the above proof, only the second property of the Euclidean function was used.
	The first property is included in the definition since it will allow us to easily describe the units in the ring.
	\[
		R^\times = \qty{u \in R \colon u \neq 0, \varphi(u) = \varphi(1)}
	\]
	It can be shown that, if there exists a function \( \varphi \) satisfying (ii), there exists a (possibly not unique) function \( \varphi' \) satisfying (i) and (ii).
\end{remark}
\begin{example}
	Let \( F \) be a field.
	Then \( F[X] \) is a Euclidean domain with Euclidean function \( \varphi(f) = \mathrm{deg}(f) \).
	We have already proven the requisite properties of Euclidean functions.

	The ring \( R = \mathbb Z[i] \) is a Euclidean domain with \( \varphi(u+iv) = N(u+iv) = u^2+v^2 \).
	Since the norm is multiplicative, \( N(zw) = N(z)N(w) \) which immediately gives property (i) in the definition.
	Consider \( z, w \in \mathbb Z[i] \) where \( w \neq 0 \).
	Consider \( \frac{z}{w} \in \mathbb C \).
	This has distance less than 1 from the nearest element \( q \) of \( R \).
	Let \( r = z - w q \in R \).
	Then \( z = w q + r \) where
	\[
		\varphi(r) = \abs{r}^2 = \abs{z - w q}^2 < \abs{w}^2 = \varphi(w)
	\]
	So property (ii) is satisfied.

	Hence \( F[X] \) and \( \mathbb Z[i] \) are principal ideal domains.
\end{example}
\begin{example}
	Let \( A \) be a nonzero \( n \times n \) matrix over a field \( F \).
	Let \( I = \qty{f \in F[X] \colon f(A) = 0} \).
	\( I \) is an ideal.
	Indeed, if \( f, g \in I \), then \( (f-g)(A) = f(A) - g(A) = 0 \), and for \( f \in I \) and \( g \in F[X] \), we have \( (f \cdot g)(A) = f(A) \cdot g(A) = 0 \) as required.
	Since \( F[X] \) is a principal ideal domain, \( I = (f) \) for some polynomial \( f \in F[X] \).
	All units in \( F[X] \) are the nonzero constant polynomials.
	Hence, the polynomial of smallest degree in \( I \) is unique up to multiplication by a unit, so without loss of generality we may assume \( f \) is monic.
	This yields the minimal polynomial of \( A \).
\end{example}
\begin{example}
	Let \( \mathbb F_2 \) be the finite field of order 2, which is isomorphic to \( \faktor{\mathbb Z}{2 \mathbb Z} \).
	Let \( f(X) \) be the polynomial \( X^3 + X + 1 \in \mathbb F_2[X] \).

	We claim that \( f \) is irreducible.
	Suppose \( f = gh \) where the degrees of \( g, h \) are positive.
	Since the degree of \( f \) is 3, one of \( g, h \) must have degree 1.
	Hence \( f \) has a root.
	But we can check that \( f(0) = f(1) = 1 \) so \( f \) has no root in \( \mathbb F_2 \).
	Hence \( f \) is irreducible as required.

	Since \( \mathbb F_2[X] \) is a principal ideal domain, we have that \( (f) \vartriangleleft \mathbb F_2[X] \) is a maximal ideal.
	Hence, \( \faktor{\mathbb F_2[X]}{(f)} \) is a field.
	We can verify that this field has order 8, using the Euclidean algorithm.
	Any element in this quotient has coset representative \( aX^2 + bX + c \) for \( a,b,c \in \mathbb F_2 \).
	We can show that all 8 of these possibilities yields different polynomials.
	So we have constructed a field of order 8.
	This technique will be explored further in Part II Galois Theory.
\end{example}
\begin{example}
	The ring \( \mathbb Z[X] \) is not a principal ideal domain.
	Consider the ideal \( I = (2, X) \vartriangleleft \mathbb Z[X] \).
	We can write
	\[
		I = \qty{2f_1(X) + Xf_2(X) \colon f_1, f_2 \in \mathbb Z[X]} = \qty{f \in \mathbb Z[X] \colon 2\mid f(0)}
	\]
	Suppose \( I = (f) \) for some element \( f \).
	Since \( 2 \in I \), we must have \( 2 = fg \) for some polynomial \( g \).
	By comparing degrees, the degrees of \( f \) and \( g \) must be zero, since \( \mathbb Z \) is an integral domain.
	Hence \( f \) is an integer, so \( f = \pm 1 \) or \( f = \pm 2 \).
	If \( f = \pm 1 \) then \( I = \mathbb Z[X] \), and if \( f = \pm 2 \) then \( I = 2\mathbb Z[X] \).
	These both lead to contradictions, since \( 1 \not\in I \) and \( X \in I \).
\end{example}

\subsection{Unique factorisation domains}
\begin{definition}
	An integral domain is a \textit{unique factorisation domain} if
	\begin{enumerate}
		\item every nonzero, non-unit element is a product of irreducibles;
		\item if \( p_1 \cdots p_m = q_1 \cdots q_n \) where \( p_i, q_i \) are irreducible, then \( m = n \), and \( p_i, q_i \) are associates, up to reordering.
	\end{enumerate}
\end{definition}
\begin{proposition}
	Let \( R \) be an integral domain satisfying property (i) above (every nonzero, non-unit element is a product of irreducibles).
	Then \( R \) is a unique factorisation domain if and only if every irreducible is prime.
\end{proposition}
\begin{proof}
	Suppose \( R \) is a unique factorisation domain.
	Let \( p \in R \) be irreducible, and \( p \mid ab \).
	Then \( ab = pc \) for some \( c \in R \).
	Writing \( a, b, c \) as products of irreducibles, it follows from uniqueness of factorisation that \( p \mid a \) or \( p \mid b \).
	Hence \( p \) is prime.

	Conversely, suppose every irreducible is prime.
	Suppose \( p_1 \cdots p_m = q_1 \cdots q_n \) where \( p_i, q_i \) are irreducible and hence prime.
	Since \( p_1 \mid q_1 \cdots q_n \), we have \( p_1 \mid q_i \) for some \( i \).
	After reordering, we may assume that \( p_1 \mid q_1 \), so \( p_1 u = q_1 \) for \( u \in R \).
	Since \( q_1 \) is irreducible, \( u \) is a unit since \( p_1 \) cannot be a unit.
	Hence \( p_1, q_1 \) are associates.
	Cancelling \( p_1 \) from both sides, we find \( p_2 \cdots p_m = u q_2 \cdots q_n \).
	We may absorb this unit into \( q_2 \) without loss of generality.
	Inductively, all \( p_i \) and \( q_i \) are associates, for each \( i \).
	Hence \( R \) is a unique factorisation domain.
\end{proof}
\begin{definition}
	Let \( R \) be a ring.
	Suppose, for all nested sequences of ideals in \( R \) written \( I_1 \subseteq I_2 \subseteq \cdots \), there exists \( N \) such that \( I_n = I_{n+1} \) for all \( n \geq N \).
	Then, we say that \( R \) is a \textit{Noetherian} ring.
\end{definition}
This condition is known as the `ascending chain condition'.
In other words, we cannot infinitely nest distinct ideals in a Noetherian ring.
\begin{lemma}
	Principal ideal domains are Noetherian rings.
\end{lemma}
\begin{proof}
	Let \( I = \bigcup_{i=1}^\infty I_i \).
	Then, \( I \) is an ideal in \( R \).
	Since \( R \) is a principal ideal domain, \( I = (a) \) for some \( a \in R \).
	Then \( a \in \bigcup_{i=1}^\infty I_i \), so in particular \( a \in I_N \) for some \( N \).
	But then for all \( n \geq N \), \( (a) \subseteq I_N \subseteq I_{n} \subseteq I_{n+1} \subseteq I = (a) \).
	So all inclusions are equalities, so in particular \( I_n = I_{n+1} \).
\end{proof}
\begin{theorem}
	If \( R \) is a principal ideal domain, then it is a unique factorisation domain.
\end{theorem}
\begin{proof}
	First, we verify property (i), that every nonzero, non-unit element is a product of irreducibles.
	Let \( x \neq 0 \) be an element of \( R \) which is not a unit.
	Suppose \( x \) does not factor as a product of irreducibles.
	This implies in particular that \( x \) is not irreducible.
	By definition, we can write \( x \) as the product of two elements \( x_1, y_1 \) where \( x_1, y_1 \) are not units.
	Then either \( x_1 \) or \( y_1 \) is not a product of irreducibles, so without loss of generality we can suppose \( x_1 \) is not a product of irreducibles.
	We have \( (x) \subset (x_1) \).
	This inclusion is strict, since \( y_1 \) is not a unit.
	Now, we can write \( x_1 = x_2 y_2 \) where \( x_2 \) is not a unit, and inductively we can create \( (x) \subset (x_1) \subset (x_2) \subset \cdots \).
	But \( R \) is Noetherian, so this is a contradiction.
	So every nonzero, non-unit element is indeed a product of irreducibles.

	By the proposition above, it suffices to show that every irreducible is prime.
	This has already been shown previously.
	Hence \( R \) is a unique factorisation domain.
\end{proof}
\begin{example}
	We have shown that all Euclidean domains are principal ideal domains, and all principal ideal domains are unique factorisation domains, and all unique factorisation domains are integral domains.
	We now provide examples for counterexamples to the converses.

	The ring \( \faktor{\mathbb Z}{4\mathbb Z} \) is not an integral domain since \( 2 \) is a zero divisor.

	The ring \( \mathbb Z[\sqrt{-5}] \leq \mathbb C \) is integral, but not a unique factorisation domain.

	The ring \( \mathbb Z[X] \) has been shown to be not a principal ideal domain.
	We can show using later results that this is a unique factorisation domain.

	We can construct the ring \( \mathbb Z\qty[\frac{1+\sqrt{-19}}{2}] \), which can be shown to be not a Euclidean domain, but is a principal ideal domain.
	This proof is beyond the scope of Part IB Groups, Rings and Modules, but will be proved in Part II Number Fields.

	Finally, \( \mathbb Z[i] \) is a Euclidean domain, and is hence a principal ideal domain, a unique factorisation domain, and an integral domain.
\end{example}
\begin{definition}
	Let \( R \) be an integral domain.
	\begin{enumerate}
		\item \( d \in R \) is a \textit{common divisor} of \( a_1, \dots, a_n \in R \) if \( d \mid a_i \) for all \( i \);
		\item \( d \in R \) is a \textit{greatest common divisor} of \( a_1, \dots, a_n \) if for all common divisors \( d' \), we have \( d' \mid d \);
		\item \( m \in R \) is a \textit{common multiple} of \( a_1, \dots, a_n \) if \( a_i \mid m \) for all \( i \);
		\item \( m \in R \) is a \textit{least common multiple} of \( a_1, \dots, a_n \) if for all common multiples \( m' \), we have \( m \mid m' \).
	\end{enumerate}
\end{definition}
\begin{remark}
	Greatest common divisors and lowest common multiples are unique up to associates, if they exist.
\end{remark}
\begin{proposition}
	In unique factorisation domains, greatest common divisors and least common multiples always exist.
\end{proposition}
\begin{proof}
	Let \( a_i = u_i \prod_j p_j^{n_{ij}} \) where the \( p_j \) are irreducible and pairwise non-associate, \( u_i \) is a unit, and \( n_{ij} \in \mathbb Z_{\geq 0} \).
	We claim that \( d = \prod_j p_j^{m_j} \), where \( m_j = \min_{1 \leq i \leq n} n_{ij} \), is the greatest common divisor.
	Certainly \( d \) is a common divisor.
	If \( d' \) is a common divisor, then \( d' \) can be written as a product of irreducibles, which will be denoted \( d' = w \prod_j p_i^{t_j} \).
	We can see that \( t_j \leq n_{ij} \) for all \( i \), so in particular, \( t_j \leq m_j \).
	This implies \( d' \mid d \).
	Hence \( d \) is a greatest common divisor.
	The argument for the least common multiple is similar, replacing minima with maxima.
\end{proof}

\subsection{Factorisation in polynomial rings}
\begin{theorem}
	Let \( R \) be a unique factorisation domain.
	Then \( R[X] \) is also a unique factorisation domain.
\end{theorem}
The proof for this theorem will require a number of key lemmas.
In this subsection, \( R \) will denote a unique factorisation domain, with field of fractions \( F \).
We have \( R[X] \leq F[X] \).
Since polynomial rings over fields are Euclidean domains, \( F[X] \) is a principal ideal domain, and hence a unique factorisation domain.
This does not immediately imply that \( R[X] \) is a unique factorisation domain, however.
\begin{definition}
	The \textit{content} of a polynomial \( f = \sum_{i=0}^n a_i X^i \in R[X] \) is \( c(f) = \mathrm{gcd}\qty{a_0, \dots, a_n} \).
	This is well-defined up to multiplication by a unit.

	We say that \( f \) is \textit{primitive} if \( c(f) \) is a unit.
\end{definition}
\begin{lemma}
	The product of primitive polynomials is primitive.
	Further, for \( f, g \in R[X] \), \( c(fg) \) and \( c(f)c(g) \) are associates.
\end{lemma}
\begin{proof}
	Let \( f = \sum_{i=0}^n a_i X^i \) and \( g = \sum_{i=0}^m b_i X^i \).
	Suppose \( fg \) is not primitive, so \( c(fg) \) is not a unit.
	This implies that there exists a prime \( p \) such that \( p \mid c(fg) \).
	Since \( f, g \) are primitive, \( p \nmid c(f) \) and \( p \nmid c(g) \).

	Suppose \( p \) does not divide all of the \( a_k \) or the \( b_\ell \).
	Let \( k, \ell \) be the smallest values such that \( p \nmid a_k \) and \( p \nmid b_\ell \).
	Then, the coefficient of \( X^{k+\ell} \) in \( fg \) is given by
	\[
		\sum_{i+j=k+\ell} a_i b_j = \underbrace{\cdots + a_{k-1} b_{\ell+1}}_{\text{divisible by } p} + a_k b_\ell + \underbrace{a_{k+1} b_{\ell - 1} + \cdots}_{\text{divisible by } p}
	\]
	Thus \( p \mid a_k b_\ell \).
	This is a contradiction as we have \( p \mid a_k \) or \( p \mid b_\ell \).

	To prove the second part, let \( f = c(f) f_0 \) for some \( f_0 \in R[X] \).
	Here, \( f_0 \) is primitive.
	Similarly, \( g = c(g) g_0 \) for a primitive \( g_0 \).
	Thus \( fg = c(f) c(g) f_0 g_0 \).
	The expression \( f_0 g_0 \) is a primitive polynomial by the first part, so \( c(fg) \) is equal to \( c(f) c(g) \) up to associates.
\end{proof}
\begin{corollary}
	If \( p \in R \) is prime in \( R \), then \( p \) is prime in \( R[X] \).
\end{corollary}
\begin{proof}
	Since \( R \) is an integral domain, we have \( R[X]^\times = R^\times \), so \( p \) is not a unit.
	Let \( f \in R[X] \).
	Then \( p \mid f \) in \( R[X] \) if and only if \( p \mid c(f) \) in \( R \).
	Thus, if \( p \mid gh \) in \( R[X] \), we have \( p \mid c(gh) = c(g) c(h) \).
	In particular, since \( p \) is prime in \( R \), we have \( p \mid c(g) \) or \( p \mid c(h) \), so \( p \mid g \) or \( p \mid h \).
	So \( p \) is prime in \( R[X] \).
\end{proof}
\begin{lemma}
	Let \( f,g \in R[X] \), where \( g \) is primitive.
	Then if \( g \mid f \) in \( F[X] \), then \( g \mid f \) in \( R[X] \).
\end{lemma}
\begin{proof}
	Let \( f = gh \), where \( h \in F[X] \).
	We can find a nonzero \( a \in R \), such that \( ah \in R[X] \).
	In particular, we can multiply the denominators of the coefficients of \( h \) to form \( a \).
	Now, \( ah = c(ah) h_0 \) where \( h_0 \) is primitive.
	Then \( af = c(ah) h_0 g \).
	Since \( h_0 \) and \( g \) are primitive, so is \( h_0 g \).
	Thus, taking contents, \( a \mid c(ah) \).
	This implies \( h \in R[X] \).
	Hence \( g \mid f \) in \( R[X] \).
\end{proof}
\begin{lemma}[Gauss' lemma]
	Let \( f \in R[X] \) be primitive.
	Then if \( f \) is irreducible in \( R[X] \), we have that \( f \) is irreducible in \( F[X] \).
\end{lemma}
\begin{proof}
	Since \( f \in R[X] \) is irreducible and primitive, its degree must be larger than zero.
	Hence \( f \) is not a unit in \( F[X] \).
	Suppose \( f \) is not irreducible in \( F[X] \), so \( f = gh \) for \( g,h \in F[X] \) with degree larger than zero.
	Let \( \lambda \in F^\times \) such that \( \lambda^{-1} g \in R[X] \) is primitive.
	For example, let \( b \in R \) such that \( bg \in R[X] \) to clear denominators, then \( bg = c(bg) g_0 \), giving \( \lambda = c(bg) b^{-1} \).
	Replacing \( g \) by \( \lambda^{-1} g \) and \( h \) by \( \lambda h \), we still have a factorisation of \( f \).
	Hence, we may assume without loss of generality that \( g \in R[X] \) and is primitive.
	By the previous lemma, we have that \( h \in R[X] \), with degrees larger than zero.
	This contradicts irreducibility.
\end{proof}
\begin{remark}
	We will see that the reverse implication in Gauss' lemma also holds.
\end{remark}
\begin{lemma}
	Let \( g \in R[X] \) be primitive.
	If \( g \) is prime in \( F[X] \), then \( g \) is prime in \( R[X] \).
\end{lemma}
\begin{proof}
	It suffices to show that if \( f_1, f_2 \in R[X] \), then \( g \mid f_1 f_2 \) implies \( g \mid f_1 \) or \( g \mid f_2 \).
	Since \( g \) is prime in \( F[X] \), \( g \mid f_1 \) or \( g \mid f_2 \) in \( F[X] \).
	By the previous lemma, \( g \mid f_1 \) or \( g \mid f_2 \) in \( R[X] \) as required.
\end{proof}
We can now prove the first theorem of this subsection, that polynomial rings over unique factorisation domains are unique factorisation domains.
\begin{proof}
	Let \( f \in R[X] \).
	Then, \( f = c(f) f_0 \) for \( f_0 \) primitive in \( R[X] \).
	Since \( R \) is a unique factorisation domain, \( c(f) \) is a product of irreducibles in \( R \).
	If an element of \( R \) is irreducible, it is irreducible as an element of \( R[X] \).
	Hence, it suffices to find a factorisation of \( f_0 \).

	Suppose \( f_0 \) is not irreducible, so \( f_0 = gh \) for \( g,h \in R[X] \).
	Since \( f_0 \) is primitive, \( g \) and \( h \) are primitive, and the degrees of \( g, h \) are larger than zero.
	By induction on the degree, we can factor \( f_0 \) as a product of primitive irreducibles in \( R[X] \).

	It now suffices to show uniqueness of the factorisation.
	By a previous proposition, it in fact suffices to show that every irreducible element of \( R[X] \) is prime.
	Let \( f \) be irreducible.
	Write \( f = c(f) f_0 \), where \( f_0 \) is primitive.
	Since \( f \) is irreducible, \( f \) must be constant or primitive.

	Suppose \( f \) is constant.
	Since \( f \) is irreducible in \( R[X] \), it must be irreducible in \( R \).
	As \( R \) is a unique factorisation domain, \( f \) is prime in \( R \).
	By a previous corollary, \( f \) is prime in \( R[X] \).

	Now, suppose \( f \) is primitive.
	Since \( f \) is irreducible in \( R[X] \), we can use Gauss' lemma to show that \( f \) is irreducible in \( F[X] \).
	Thus, \( f \) is prime in \( F[X] \), as \( F[X] \) is a unique factorisation domain.
	Finally, we can see that \( f \) is prime in \( R[X] \) by the previous lemma.
\end{proof}
\begin{remark}
	We know that the prime elements in an integral domain are irreducible.
	This implies that the implications in the last paragraph above are in fact equivalences.
	In particular, in Gauss' lemma, the implication is an equivalence.
\end{remark}
\begin{example}
	The above theorem implies that \( \mathbb Z[X] \) is a unique factorisation domain.

	Let \( R[X_1, \dots, X_n] \) be the ring of polynomials in \( n \) variables.
	We can rewrite this as \( R[X_1]\dots[X_n] \), so by induction this is a unique factorisation domain if \( R \) is.
\end{example}

\subsection{Eisenstein's criterion}
\begin{proposition}
	Let \( R \) be a unique factorisation domain, and \( f(X) = \sum_{i=0}^n a_i X^i \in R[X] \) be a primitive polynomial.
	Let \( p \in R \) be irreducible (or, equivalently, prime) such that
	\begin{enumerate}
		\item \( p \nmid a_n \);
		\item \( p \mid a_i \) for all \( i < n \); and
		\item \( p^2 \nmid a_0 \).
	\end{enumerate}
	Then \( f \) is irreducible in \( R[X] \).
\end{proposition}
\begin{proof}
	Suppose \( f = gh \) for \( g,h \in R[X] \) not units.
	Since \( f \) is primitive, \( g, h \) must have positive degree.
	Let \( g(X) = \sum_{i=0}^k r_i X^i \) and \( h(X) = \sum_{i=0}^\ell s_i X^i \), so \( k + \ell = n \).
	Then \( p \nmid a_n = r_k s_\ell \), so \( p \nmid r_k \) and \( p \nmid s_\ell \).
	Further, \( p \mid a_0 = r_0 s_0 \) so \( p \mid r_0 \) or \( p \mid s_0 \).
	Without loss of generality, we may assume \( p \mid r_0 \).
	There exists a minimal \( j \leq k \) such that \( p \mid r_i \) for all \( i < j \) but \( p \nmid r_j \).
	\[
		a_j = r_0 s_j + r_1 s_{j-1} + \dots + r_{j-1} s_1 + r_j s_0
	\]
	By assumption, \( a_j \) is divisible by \( p \) since \( j < n \).
	Further, the first \( j \) terms in the expansion are divisible by \( p \).
	Thus, \( p \mid r_j s_0 \).
	By assumption, \( p \nmid r_j \), so \( p \mid s_0 \).
	In particular, \( p^2 \mid r_0 s_0 = a_0 \), contradicting the third criterion.
\end{proof}
\begin{example}
	Let \( f(X) = X^3 + 2X + 5 \in \mathbb Z[X] \).
	We will show this is irreducible as a polynomial over \( \mathbb Q \).
	If \( f \) is not irreducible in \( \mathbb Z[X] \), then it factorises as \( f(X) = (X+a)(X^2 + bX + c) \) up to multiplication by units.
	Here, \( ac = 5 \).
	But \( \pm 1, \pm 5 \) are not roots of \( f \), so this is irreducible in \( \mathbb Z[X] \).
	By Gauss' lemma, \( f \) is irreducible in \( \mathbb Q[X] \), since \( \mathbb Q \) is the field of fractions of \( \mathbb Z \).
	In particular, \( \faktor{\mathbb Q[X]}{(f)} \) is a field, since the ideal \( (f) \) is maximal.
\end{example}
\begin{example}
	Let \( p \in \mathbb Z \) be a prime, and let \( f(X) = X^n - p \).
	By Eisenstein's criterion, \( f \) is irreducible in \( \mathbb Z[X] \).
	It is then irreducible in \( \mathbb Q[X] \) by Gauss' lemma.
\end{example}
\begin{example}
	Consider \( f(X) = X^{p-1} + X^{p-2} + \dots + X + 1 \in \mathbb Z[X] \), where \( p \) is prime.
	Eisenstein's criterion does not apply directly.
	Consider
	\[
		f(X) = \frac{X^p - 1}{X - 1};\quad Y = X - 1
	\]
	By using this substitution of \( Y \),
	\[
		f(Y+1) = \frac{(Y+1)^p - 1}{Y-1 + 1} = Y^{p-1} + \binom{p}{1} Y^{p-2} + \dots + \binom{p}{p-2} Y + \binom{p}{p-1}
	\]
	We can apply Eisenstein's criterion to this new polynomial, since \( p \mid \binom{p}{i} \) for all \( 1 \leq i \leq p - 1 \), and \( p^2 \nmid \binom{p}{p-1} = p \).
	Thus, \( f(Y+1) \) is irreducible in \( \mathbb Z[Y] \), so \( f(X) \) is irreducible in \( \mathbb Z[X] \).
	Of course, \( f(X) \) is therefore irreducible in \( \mathbb Q[X] \) as before.
\end{example}
